package com.zhixun.mobile.modules.ads.web;

import java.io.IOException;
import java.text.ParseException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.boxin.ims.modules.ad.entity.Advertisement;
import com.boxin.ims.modules.ad.service.AdvertisementService;
import com.boxin.ims.modules.wechat.entity.LotteryRecord;
import com.boxin.ims.modules.wechat.service.LotteryRecordService;
import com.thinkgem.jeesite.common.config.Global;
import com.zhixun.mobile.modules.base.web.BaseController;


/**
 * @author Administrator
 * @date 2014-4-30
 * @function <p>广告处理器 </p>
 */
@Controller
@RequestMapping(value = Global.FRONT_PATH+"/advert")
public class AdvertisementFrontController  extends BaseController {
	
	
	@Autowired
	private AdvertisementService advertisementService;
	
	@Autowired
	private LotteryRecordService lotteryRecordService;
	
	@RequestMapping(value = "view")// TODO 会员登录
	public String login(Long id,Long uid,Long memberId,Long lotteryId,HttpServletRequest request,	HttpServletResponse response, Model model,	RedirectAttributes redirectAttributes)
			throws NumberFormatException, IOException, ParseException {
		
		String wechatId = request.getParameter("wechatId");		//OpenId
		
		advertisementService.clear();
		Advertisement  advertisement = advertisementService.get(id);
		
		LotteryRecord  lottery = lotteryRecordService.get(lotteryId);
		
		model.addAttribute("advert", advertisement);
		model.addAttribute("lottery", lottery);
		
		
		return "/modules/advert/advertView";
	}

}
